<?php
class LogUtils {
  public static function add_signin_log($myPdo, $account) {
    $log = new stdClass();
    $log->date1 = date('Y-m-d H:i:s');
    $log->account = $account;
    $log->ip = LogUtils::_get_ip();
    DbUtils::add($myPdo, TABLE_NAME_PREFIX_MODULE . 'data_signin_log', $log);
  }
  
  public static function add_operator_log($myPdo, $order, $type, $status) {
    $log = new stdClass();
    $log->date1 = date('Y-m-d H:i:s');
    $log->order_track_id = $order->track_id;
    $log->order_type = $type;
    $log->order_status = $status;
    $log->operator = $order->operator;
    $log->operator_date = $order->operator_date;
    DbUtils::add($myPdo, TABLE_NAME_PREFIX_MODULE . 'data_operator_log', $log);
  }
  
  public static function _get_ip() {
		$ch = curl_init('http://iframe.ip138.com/ic.asp');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$a = curl_exec($ch);
		preg_match('/\[(.*)\]/', $a, $ip);
		
		return $ip[1]; 
  }
}
?>